<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="MultiPackage.aspx.cs" Inherits="MultiPackage" Title="Magnolia - Editor" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Assembly="Microsoft.Web.Preview" Namespace="Microsoft.Web.Preview.UI.Controls" TagPrefix="cc2" %>

<asp:Content ID="Content_MultiPackage" ContentPlaceHolderID="ContentPlaceHolder_Main" Runat="Server">
<script src="Scripts/editorevents.js" type="text/javascript"></script>
<script src="Scripts/editor.js" type="text/javascript"></script>
<script src="Scripts/lists.js" type="text/javascript"></script>
<script src="Scripts/draggables.js" type="text/javascript"></script>

<form id="Form_MultiPackage" runat="server" oncontextmenu="return false;">
<asp:HiddenField ID="Hidden_EditorHeader" runat="server" />
<asp:HiddenField ID="Hidden_ListLookupIDs" runat="server" />
<asp:HiddenField ID="Hidden_ListLookupCount" runat="server" />
<asp:HiddenField ID="Hidden_EditorPageID" runat="server" />
<asp:HiddenField ID="Hidden_SessionID" runat="server" />
<asp:HiddenField ID="Hidden_UserID" runat="server" />
<asp:ListBox ID="ListBox_UserAccess" runat="server"></asp:ListBox>

<asp:ScriptManager ID="ScriptManager_MultiPackage" runat="server">
</asp:ScriptManager>

<!-- multipackage editor start -->
<div id="multiPackage" style="display:none;">
<!-- page title start -->
<h1>
	<span><asp:Label ID="Lbl_MultiPackageHeader" runat="server" Text=""></asp:Label></span>
	<input id="multiPackageReturn" type="button" value="" />
</h1>
<!-- page title end -->

<!-- main content start -->
<div class="mainHolder">
<!-- left block start -->
<div class="leftBlock">
	<h2>
		<span>Add Event to Packages</span>
	</h2>
	<div class="innerBlock">
        <h3>
			<span>Search</span>
			<a href="#" class="switch">Open/Collapse</a>
		</h3>
		<div class="innerContent">
		    <div id="multiPackage_SearchFields"></div>
		    <div id="eventSearchButtons" class="row" style="display:none;">
                <input id="multiPackageSearch" type="button" value="Search" onclick="getSearchResults();" />
                <div class="spacerS"></div>
	            <input id="multiPackageReset" type="button" value="Reset" onclick="resetSearchFields('multiPackage_SearchFields');"/>
	        </div>
	    </div>
	</div>
	<div class="innerBlock">
	    <h3>
		    <span>Search Results</span>
		    <a href="#" class="switch">Open/Collapse</a>
	    </h3>
        <div class="innerContent">
            <div id="multiPackage_SearchAlerts" class="row" style="display:none;"></div>
            <div class="row">
	            <div class="col">
		            <select id="multiPackageSort" onchange="sortResults(this, 'multiPackageResults');" disabled="disabled">
		                <option selected="selected" value="0">Sort By</option>
			            <option value="1">Name</option>
			            <option value="2">Newest</option>						
		            </select>
		        </div>
		        <div class="col" style="float:right;">
                    <input id="multiPackageAdd" type="button" value="Add >>" disabled="disabled" onclick="activeEditor.addFromIcon();"/>
                </div>
	        </div>
	        <div class="row">
                <select id="multiPackageResults" multiple="multiple"  class="heightL width100" onchange="resultsIndexChanged(this);" ondblclick="activeEditor.addFromIcon();">
                </select>
            </div>
        </div>
	</div>
</div>
<!-- left block end -->

<!-- right block start -->
	<div class="rightBlock">
		<h2>
			<span>Package Editor - Multiple Packages</span>
    	<input id="multiPackage_Cancel" type="button" style="display:none;" value="Cancel Changes" onclick="checkReturn(this, 'PackageList.aspx');" />
		<input id="multiPackage_Save" type="button" value="Save Packages..." style="display:none;" onclick="showSaveMultiplePackages();" />
		</h2>
		<div id="multiPackage_Messages" class="errorMsg"></div>
		<div class="innerBlock">
			<h3>
				<span>Editor</span>
				<a href="#" class="switch">Open/Collapse</a>
			</h3>
            <div class="innerContent" id="multiPackageDDEditorContainer">
	        </div>		
		</div>	
	</div>
<!-- right block end -->
</div>
<!-- main content end --> 
</div>
<!-- package editor end -->

<!-- draggable info panel -->  
<asp:Panel ID="Panel_GetInfo" runat="server" Width="223" CssClass="popupPanel" >
<div id="getInfoPanel">
    <strong>
        <span>Info</span>
        <img alt="Close" src="Images/close.gif" style="float:right; margin:0 5px 0 0; border:none; display:inline; cursor:pointer;" onclick="resetGetInfo();" />
        <!--<a href="#" onclick="resetGetInfo();">Close</a>-->
    </strong>
    <div id="getInfo_NothingSelected" style="display:block; float:left; padding:5px;">Nothing selected...</div>
    <div id="getInfo_MultipleSelected" style="display:none; float:left; padding:5px;">Multiple items selected...</div>
    <dl id="infoInner" class="inner">
    </dl>
</div>
</asp:Panel>
<cc2:DragOverlayExtender ID="DragOverlayExtender2" runat="server" TargetControlID="Panel_GetInfo" Enabled="true" />
<cc1:DropShadowExtender ID="DropShadowExtender1" runat="server" 
    TargetControlID="Panel_GetInfo" 
    Rounded="false"
    Width="5"
    Opacity="0.25" 
    TrackPosition="true"  />
<!-- end draggable info panel -->       

<!-- package context-sensitive menu -->
<div id="packageListMenu" ondblclick="if (this.style.display = 'block') {this.style.display = 'none';}"  style="background-color:Black;">
    <ul class="drop">
        <li id="packageListMenuCopy"><a href="#" onclick="hideMenu(); activeEditor.copyToClip();">Copy</a></li>
        <li id="packageListMenuCut"><a href="#" onclick="hideMenu(); activeEditor.cutToClip();">Cut</a></li>
        <li id="packageListMenuPaste" class="wSep"><a href="#" onclick="hideMenu(); activeEditor.checkPasteFromClip();">Paste</a></li>
        <li id="packageListMenuClear"><a href="#" onclick="hideMenu(); activeEditor.checkClearList();">Clear Contents</a></li></ul>
</div>
<!-- package context-sensitive menu ends -->

<!-- event context-sensitive menu -->
<div id="eventMenu" ondblclick="if (this.style.display = 'block') {this.style.display = 'none';}"  style="background-color:Black;">
    <ul class="drop">
        <li id="eventMenuCopy"><a href="#" onclick="hideMenu(); activeEditor.copyToClip();">Copy</a></li><li id="eventMenuCut"><a href="#" onclick="hideMenu(); activeEditor.cutToClip();">Cut</a></li><li id="eventMenuPaste" class="wSep"><a href="#" onclick=" hideMenu(); activeEditor.checkPasteFromClip();">Paste</a></li><li id="eventMenuAdd"><a href="#" onclick="hideMenu(); activeEditor.addFromIcon();">Add</a></li><li id="eventMenuRemove" class="wSep"><a href="#" onclick="hideMenu(); activeEditor.remove();">Remove</a></li><li id="eventMenuHotKeys" class="wSep"><a href="#" onclick="hideMenu();" onmouseover="activeEditor.showHKMenu();" onmouseout="activeEditor.hideHKMenu();">Assign Hot Key</a></li><li id="eventMenuLoop"><a href="#" onclick="hideMenu(); showLoop();">Loop&hellip;</a></li></ul>
</div>
<!-- event context-sensitive menu ends -->

<!-- unsaved changes popup begins -->
<asp:Panel ID="Panel_UnsavedChanges" runat="server" CssClass="popupPanel">
<div id="unsavedChangesAlert" class="unsavedChanges">
    <strong>
        <span>Unsaved Changes</span>
        <%--<a href="#" class="close">Close</a>--%>
    </strong>
    <div class="inner">
	    <label>
		    You have unsaved changes. Continue?  
	    </label>
	    <br />
	    <input type="button" value="Save Changes" onclick="saveContinue(true);"/>
	    <div class="spacerM"></div>
	    <input type="button" value="Don't Save Changes" onclick="saveContinue(false);" />
	    <div class="spacerM"></div>
	    <input type="button" value="Cancel" onclick="$('unsavedChangesAlert').style.display = 'none';" />
    </div>
</div>
</asp:Panel>
<cc2:DragOverlayExtender ID="DragOverlayExtender3" TargetControlID="Panel_UnsavedChanges" runat="server" Enabled="true" />
<cc1:DropShadowExtender ID="DropShadowExtender3" runat="server"
    TargetControlID="Panel_UnsavedChanges" 
    Rounded="false"
    Width="5"
    Opacity="0.25" 
    TrackPosition="true"  />
<!-- unsaved changes popup ends -->

<!-- hot key panel -->  
<asp:Panel ID="Panel_HK_MultiPackageEvents" runat="server" Width="180" CssClass="popupHKPanel" >
<div id="draggablehotkeys_multiPackage" class="hotkeys">
    <strong>
        <span>Hot Keys - Events</span>
        <a href="#" class="close">Close</a>
    </strong>
    <div class="inner">
        <div class="row">
            <span style="float:left; font-weight:bold; padding-top:2px;">1&nbsp;&nbsp;&nbsp;</span><div id="event_HK1" ondblclick="activeEditor.addFromHK(1);" class="hkBox">Empty</div>
        </div>
        <div class="row">
            <span style="float:left; font-weight:bold; padding-top:2px;">2&nbsp;&nbsp;&nbsp;</span><div id="event_HK2" ondblclick="activeEditor.addFromHK(2);" class="hkBox">Empty</div>
        </div>
        <div class="row">
            <span style="float:left; font-weight:bold; padding-top:2px;">3&nbsp;&nbsp;&nbsp;</span><div id="event_HK3" ondblclick="activeEditor.addFromHK(3);" class="hkBox">Empty</div>
        </div>
        <div class="row">
            <span style="float:left; font-weight:bold; padding-top:2px;">4&nbsp;&nbsp;&nbsp;</span><div id="event_HK4" ondblclick="activeEditor.addFromHK(4);" class="hkBox">Empty</div>
        </div>
        <div class="row">
            <span style="float:left; font-weight:bold; padding-top:2px;">5&nbsp;&nbsp;&nbsp;</span><div id="event_HK5" ondblclick="activeEditor.addFromHK(5);" class="hkBox">Empty</div>
        </div>
    </div>
</div>
</asp:Panel>
<cc2:DragOverlayExtender ID="DragOverlayExtender_HK_MultiPackageEvents" runat="server" TargetControlID="Panel_HK_MultiPackageEvents" Enabled="true" />
<cc1:DropShadowExtender ID="DropShadowExtender_HK_MultiPackageEvents" runat="server" 
    TargetControlID="Panel_HK_MultiPackageEvents" 
    Rounded="false"
    Width="5"
    Opacity="0.25" 
    TrackPosition="true"  />
<!-- end hot key panel -->

<!-- hot key sub menu -->
<div id="hotKeyMenu" onmouseover="this.style.display='block';" onmouseout="this.style.display='none';" style="background-color:Black;">
    <ul class="drop">
        <li id="hotKeyMenu_1"><a href="#" onclick="hideMenu(); activeEditor.assignHotKey(1);">Slot 1</a></li><li id="hotKeyMenu_2"><a href="#" onclick="hideMenu(); activeEditor.assignHotKey(2);">Slot 2</a></li><li id="hotKeyMenu_3"><a href="#" onclick="hideMenu(); activeEditor.assignHotKey(3);">Slot 3</a></li><li id="hotKeyMenu_4"><a href="#" onclick="hideMenu(); activeEditor.assignHotKey(4);">Slot 4</a></li><li id="hotKeyMenu_5"><a href="#" onclick="hideMenu(); activeEditor.assignHotKey(5);">Slot 5</a></li></ul>
</div>
<!-- hot key sub menu ends -->   

<!-- multi-select context-sensitive menu -->
<div id="multiSelectMenu" ondblclick="if (this.style.display = 'block') {this.style.display = 'none';}"  style="background-color:Black;">
    <ul class="drop">
        <li id="multiSelectMenuCopy"><a href="#" onclick="hideMenu(); activeEditor.copyToClip();">Copy</a></li><li id="multiSelectMenuCut"><a href="#" onclick="hideMenu(); activeEditor.cutToClip();">Cut</a></li></ul>
</div>
<!-- multi-select context-sensitive menu ends -->

<!-- loop menu begins -->
<asp:Panel ID="Panel_Loop" runat="server" CssClass="popupPanel" >
<div id="loopPopup" class="loop">
	<div class="form">
		<strong>
			<span>Loop</span>
		</strong>
		<div class="inner">
		    <div class="row">
			    <div style="margin-left:10px;" class="col">
			        <input type="radio" id="loopOptionFill" onclick="$('loopOptionUntil').checked = false;" />&nbsp;Fill Available
			    </div>
		    </div>
		    <div class="row">
			    <div style="margin-left:10px; margin-top:3px;" class="col">
			        <input type="radio" id="loopOptionUntil" onclick="$('loopOptionFill').checked = false;"/>
		            &nbsp;Loop Until
		        </div>
	            <div class="spacerXL"></div>
	            <div class="col">
                    <select id="loopSelect" onchange="updateLoopOptions();">
                        <option>Select</option>
                    </select>
                </div>
		    </div>
		    <div class="row" style="margin:4px 0 0 10px;">
		        <div class="col">
			        <input type="button" name="submit" value="Loop" id="loopSubmit" onclick="hideLoop(); checkLoop();" />
			    </div>
			    <div class="spacerXL"></div>
			    <div class="col">
			        <input type="button" name="submit" value="Cancel" onclick="hideLoop();"/>
		        </div>
		    </div>
	    </div>
    </div>
</div>
</asp:Panel>
<cc2:DragOverlayExtender ID="DragOverlayExtender_Loop" runat="server" TargetControlID="Panel_Loop" Enabled="true" />
<cc1:DropShadowExtender ID="DropShadowExtender_Loop" runat="server" 
    TargetControlID="Panel_Loop" 
    Rounded="false"
    Width="5"
    Opacity="0.25" 
    TrackPosition="true"  />
<!-- loop menu ends -->

<!-- yes/no popup begins -->
<asp:Panel ID="Panel_YesNo" runat="server" Width="300" CssClass="popupPanel">
<div id="yesNoPopup" class="yesNoAlert">
    <strong id="yesNoHeader">
        <span id="yesNoSpan"></span>
        <!--<a href="#" class="close">Close</a>-->
    </strong>
    <div class="inner">
	    <label id="yesNoLabel">
	    </label>
	    <br />
	    <input id="yesNo_YesBtn" type="button" value="Yes" />
	    <div class="spacerXL"></div>
	    <input id="yesNo_NoBtn"type="button" value="No" />
    </div>
</div>
</asp:Panel>
<cc2:DragOverlayExtender ID="DragOverlayExtender_YesNo" TargetControlID="Panel_YesNo" runat="server" Enabled="true" />
<cc1:DropShadowExtender ID="DropShadowExtender_YesNo" runat="server"
    TargetControlID="Panel_YesNo" 
    Rounded="false"
    Width="5"
    Opacity="0.25" 
    TrackPosition="true"  />
<!-- yes/no popup ends -->

<!-- open for edit popup begins -->
<asp:Panel ID="Panel_OpenForEdit" runat="server" Width="300" CssClass="popupPanel">
<div id="openForEditAlert" class="openForEdit">
    <strong>
        <span id="openForEdit_Span"></span>
        <a href="#" class="close">Close</a>
    </strong>
    <div class="inner">
	    <label id="openForEdit_Label">
	    </label>
	    <!--<br />
	    <input id="Button1" type="button" value="OK"/>-->
    </div>
</div>
</asp:Panel>
<cc2:DragOverlayExtender ID="DragOverlayExtender_OpenForEdit" TargetControlID="Panel_OpenForEdit" runat="server" Enabled="true" />
<!-- open for edit popup ends -->

<!-- yes/no popup begins -->
<asp:Panel ID="Panel_SaveMultiplePackages" runat="server" Width="300" CssClass="popupPanel">
<div id="saveMultiPackage" class="unsavedChanges">
    <strong>
        <span style="width:295px;">Save Packages</span>
        <!--<a href="#" class="close">Close</a>-->
    </strong>
    <div class="inner">
        <div class="row">
	    <label>Choose which packages you would like to save
	    </label>
	    </div>
	    <div id="saveMultiRow0" class="row" style="display:none;">
	        <input id="saveMultiCheck0" type="checkbox" /><span id="saveMultiName0"></span>
	    </div>
	    <div id="saveMultiRow1" class="row" style="display:none;">
	        <input id="saveMultiCheck1" type="checkbox" /><span id="saveMultiName1"></span>
	    </div>
	    <div id="saveMultiRow2" class="row" style="display:none;">
	        <input id="saveMultiCheck2" type="checkbox" /><span id="saveMultiName2"></span>
	    </div>
	    <br />
	    <div class="row">
	        <input type="button" value="Save" onclick="saveMultiplePackages();" />
	        <div class="spacerM"></div>
	        <input type="button" value="Cancel" onclick="hideSaveMultiplePackages();" />
	    </div>
    </div>
</div>
</asp:Panel>
<cc2:DragOverlayExtender ID="DragOverlayExtender_SaveMultiplePackages" TargetControlID="Panel_SaveMultiplePackages" runat="server" Enabled="true" />
<cc1:DropShadowExtender ID="DropShadowExtender_SaveMultiplePackages" runat="server"
    TargetControlID="Panel_SaveMultiplePackages" 
    Rounded="false"
    Width="5"
    Opacity="0.25" 
    TrackPosition="true"  />
<!-- yes/no popup ends -->

<!-- debugging box -->
<div id="coordBox" style="display:none">
    <span id="mouseCoords">(x,y): </span><br />
    <!--<span id="dropPoint">drop point: </span><br />
    <span id="dropBoxId">drop box id: </span><br />
    <span id="affectedArray">affected: </span><br />-->
    <span id="dropsIndex">drops index: </span><br />    
    <span id="numDrags">draggables: </span><br />
    <span id="numDrops">droppables: </span><br />
    <span id="activeDrag">active drag: </span><br />  
    <span id="activeDrop">active drop: </span><br />  
    <span id="activeList">active list: </span><br />
</div>

<script type="text/javascript">      
    
    // assign all global javascript variables
    sessionId = "<%= Hidden_SessionID.Value %>";
    userId = "<%= Hidden_UserID.Value %>";
    activeEditorPageId = "<%= Hidden_EditorPageID.Value %>"; 
    multiPackageListLookupIds = "<%= Hidden_ListLookupIDs.Value %>".split('_');
    multiPackageCount = parseInt("<%= Hidden_ListLookupCount.Value %>",10); 
    multiPackageHeader = $('<%= Lbl_MultiPackageHeader.ClientID %>');
    multiPackageReturnButton = $('multiPackageReturn');    
    multiPackageCancelButton = $('multiPackage_Cancel'); 
       
    // apply user access restrictions
    accessList = $('<%= ListBox_UserAccess.ClientID %>');
    applyUserAccess('MultiPackage');
    multiPackageReturnButton.value = "Return to Package List";
    multiPackageReturnButton.setAttribute('onclick', 'checkReturn(this, "PackageList.aspx");');
    $(activeEditorPageId).style.display = "block";
    loadMultiPackageEditor();
    
    function showSaveMultiplePackages() {
        // check durations first
        var durationStr = "00:30:00";
        var longestDurationStr = getLongestDuration();
        
        // check duration       
        if (longestDurationStr > durationStr) {
            var msgNode = $('multiPackage_Messages');
            msgNode.style.color = "Red";
            msgNode.innerHTML = "&#149; One of the package lists exceeds 30 minutes"
            msgNode.style.display = "block";
            return;
        } 
        
        // assign names to popup
        for (var i=0; i<multiPackageCount; i++) {
            var rowStr = "saveMultiRow" + i;
            var nameStr = "saveMultiName" + i;
            $(nameStr).innerHTML = activeEditor.headerText[i];
            $(rowStr).style.display = "block";
        }
        $('saveMultiPackage').style.display = "block";
    }
    
    function hideSaveMultiplePackages() {
        // remove names and hide rows
        for (var i=0; i<multiPackageCount; i++) {
            var rowStr = "saveMultiRow" + i;
            var nameStr = "saveMultiName" + i;
            var checkStr = "saveMultiCheck" + i;
            $(checkStr).checked = false;
            $(nameStr).innerHTML = "";
            $(rowStr).style.display = "none";
        }
        $('saveMultiPackage').style.display = "none";
    }
    
    function convertToBoolString(value) {
        return (value == 1) ? "true" : "false";
    }
    
	function saveMultiplePackages() {
	    // find which packages to save
	    saveLists = [];
	    for (var i=0; i<multiPackageCount; i++) {
            var checkStr = "saveMultiCheck" + i;  
            if ($(checkStr).checked == true) {
                saveLists.push(i);
            }
        }
	    if (saveLists.length == 0) return;
	    var successfulSaves = [];
	    for (var i=0, len=saveLists.length; i<len; i++) {
            var multiPackageSaveRequest = new XMLHttpRequest();
            // get package parameters
            var index = saveLists[i];
            var packageObj = multiPackageRequest[0].responseXML.getElementsByTagName('PACKAGE')[index];
            
            
            // fill out form        
            var idStr = "ID=\"" + packageObj.getAttribute('ID') + "\" ";
            var nameStr = "Name=\"" + packageObj.getAttribute('Name') + "\" ";
            var systemIdStr = (packageObj.getAttribute('SystemID')) ? ("SystemID=\"" + packageObj.getAttribute('SystemID') + "\" ") : "";
            var thisEnabledStr = "ThisEnabled=\"" + convertToBoolString(packageObj.getAttribute('ThisEnabled')) + "\" ";
            var thisDayPartStr = (packageObj.getAttribute('ThisDayPart')) ? ("ThisDayPart=\"" + packageObj.getAttribute('ThisDayPart') + "\" ") : "";
            var thisStartDateStr = (packageObj.getAttribute('ThisStartDate')) ? ("ThisStartDate=\"" + packageObj.getAttribute('ThisStartDate') + "\" ") : "";
            var thisEndDateStr = (packageObj.getAttribute('ThisEndDate')) ? ("ThisEndDate=\"" + packageObj.getAttribute('ThisEndDate') + "\" ") : "";
            var thisColorStr = (packageObj.getAttribute('ThisColor')) ? ("ThisColor=\"" + packageObj.getAttribute('ThisColor') + "\" ") : "";
            var cueStringStartStr = (packageObj.getAttribute('CueStringStart')) ? ("CueStringStart=\"" + packageObj.getAttribute('CueStringStart') + "\" ") : "";
            var cueStringEndStr = (packageObj.getAttribute('CueStringEnd')) ? ("CueStringEnd=\"" + packageObj.getAttribute('CueStringEnd') + "\" ") : "";   
                
            // create save xml
            var xmlStr = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
            xmlStr += "<ROOT>";
            xmlStr += "<STOREDPROCEDURE Name=\"sproc_WEB_UpdateFromBLPackageMultiple\" />";
            xmlStr += "<BL_PACKAGE BLID=\"\" SessionID=\"" + sessionId + "\" Duration=\"1900-01-01T00:30:00\" EnabledNN=\"false\" IngestedNN=\"false\" OnPlayersNN=\"false\" IsWebControlPackage=\"false\" ";
            xmlStr += idStr + nameStr + systemIdStr + thisEnabledStr + thisDayPartStr + thisStartDateStr + thisEndDateStr + thisColorStr + cueStringStartStr + cueStringEndStr; 
            xmlStr += " />";
            // add packagespots
            xmlStr += activeEditor.ddLists[index].saveItems();
            xmlStr += "</ROOT>";
            
            var url = "AjaxPost.aspx";
            multiPackageSaveRequest.open('POST', url, false);
            multiPackageSaveRequest.setRequestHeader("Content-Type", "text/xml");
            multiPackageSaveRequest.send(xmlStr);
            if (multiPackageSaveRequest.readyState == 4) {
	            if (multiPackageSaveRequest.status == 200) {
	                successfulSaves.push(packageObj.getAttribute('Name'));
	                continue;
	            }
	        }
	    }
	    
	    var msgNode = $('multiPackage_Messages');
	    if (successfulSaves.length > 0) {
            msgNode.innerHTML = "Packages saved: ";
            for (var i=0; i<successfulSaves.length; i++) {
                if ( (parseInt(i,10)+1) != successfulSaves.length )
                    msgNode.innerHTML += successfulSaves[i] + ", ";
                else
                    msgNode.innerHTML += successfulSaves[i];
            }            
            msgNode.style.color = "green";
            msgNode.style.display = "block";
        }
        setPageModified(false);
        hideSaveMultiplePackages();
	}     
    
//	function saveMultiplePackages() {
//	    // find which packages to save
//	    saveIds = [];
//	    saveNames = [];
//	    saveEnableds = [];
//	    for (var i=0; i<multiPackageCount; i++) {
//            var checkStr = "saveMultiCheck" + i;  
//            if ($(checkStr).checked == true) {
//                saveIds.push(activeEditor.listLookupIds[i]);
//                var nameStr = "saveMultiName" + i;
//                saveNames.push($(nameStr).innerHTML);
//                var enabled = multiPackageRequest[0].responseXML.getElementsByTagName('PACKAGE')[i].getAttribute('ThisEnabled');
//                if (enabled == 1) saveEnableds.push('true');
//                if (enabled == 0) saveEnableds.push('false');
//            }
//        }
//	    if (saveIds.length == 0) return;
//	    var successfulSaves = [];
//	    for (var i=0, len=saveIds.length; i<len; i++) {
//            var multiPackageSaveRequest = new XMLHttpRequest();
//            
//            // create save xml
//            var xmlStr = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
//            xmlStr += "<ROOT>";
//            xmlStr += "<STOREDPROCEDURE Name=\"sproc_WEB_UpdateFromBLPackage\" />";
//            xmlStr += "<BL_PACKAGE BLID=\"\" SessionID=\"" + sessionId + "\" ID=\"" + saveIds[i] + "\" ";
//            xmlStr += "Name=\"" + saveNames[i] + "\" Duration=\"1900-01-01T00:30:00\" ThisEnabled=\"" + saveEnableds[i] + "\" EnabledNN=\"false\" IngestedNN=\"false\" OnPlayersNN=\"false\" IsWebControlPackage=\"false\" />";
//            if (i==0) xmlStr += activeEditor.ddLists[0].saveItems();
//            if (i==1) xmlStr += activeEditor.ddLists[1].saveItems();
//            if (i==2) xmlStr += activeEditor.ddLists[2].saveItems();
//            xmlStr += "</ROOT>";
//            
//            var url = "AjaxPost.aspx";
//            multiPackageSaveRequest.open('POST', url, false);
//            multiPackageSaveRequest.setRequestHeader("Content-Type", "text/xml");
//            multiPackageSaveRequest.send(xmlStr);
//            if (multiPackageSaveRequest.readyState == 4) {
//	            if (multiPackageSaveRequest.status == 200) {
//	                successfulSaves.push(saveNames[i]);
//	                continue;
//	            }
//	        }
//	    }
//	    
//	    var msgNode = $('multiPackage_Messages');
//	    if (successfulSaves.length > 0) {
//            msgNode.innerHTML = "Packages saved: ";
//            for (var i=0; i<successfulSaves.length; i++) {
//                if ( (parseInt(i,10)+1) != successfulSaves.length )
//                    msgNode.innerHTML += successfulSaves[i] + ", ";
//                else
//                    msgNode.innerHTML += successfulSaves[i];
//            }            
//            msgNode.style.color = "green";
//            msgNode.style.display = "block";
//        }
//        setPageModified(false);
//        hideSaveMultiplePackages();
//	} 
    
</script> 

</form>
</asp:Content>